import {CanActivateFn, Router} from '@angular/router';
import { NzMessageService } from 'ng-zorro-antd/message';
import {inject} from '@angular/core';
import {AuthService} from '../services/auth.service';
export const authGuard: CanActivateFn = (route, state) => {
  const message = inject(NzMessageService)
  const authService = inject(AuthService);
  const router = inject(Router);
  if(!authService.getToken()) {
    message.warning("请先登录")
    router.navigate(['/login'])
    return false
  }
  return true;
};
